<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../../assets/img/favicon-144.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../../assets/img/favicon-144.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../../assets/img/favicon-72.png">
<link rel="apple-touch-icon-precomposed" href="../../assets/img/favicon-32.png">
<link rel="shortcut icon" href="../../assets/img/favicon-32.png">

<link rel="stylesheet" href="../../assets/css/vk.css"/>
<link rel="stylesheet" href="../../assets/css/prism.css"/>


<vk-title>ArrayBuffer | NVK</vk-title>

<vk-centered>

  <vk-navigation>
  <vk-search-title>Search</vk-search-title>
  <vk-search>
    <input type="text" id="search" autocomplete="off" />
    <vk-search-results>
      <ol id="search-list">
        <li id="no-search-results">No Results</li>
      </ol>
    </vk-search-results>
  </vk-search>
  <vk-section-title style="margin-top: 1em;">Categories</vk-section-title>
  <vk-categories></vk-categories>
</vk-navigation>


  <vk-struct>

    <vk-name>ArrayBuffer</vk-name>

    <vk-description><i>nvk</i> extends the <vk-property-type type="arraybuffer"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a></vk-property-type> Object with additional low-level methods.</vk-description>

    </vk-stub><vk-section-title>Additional Properties</vk-section-title>

    <vk-properties>

      <!-- getAddress -->
      <vk-property-entry>
        <vk-property-prototype>ArrayBuffer.prototype.<vk-prototype-name>getAddress</vk-prototype-name></vk-property-prototype>
        <vk-property-type type="number"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt">BigInt</a></vk-property-type>
        <vk-property-description>Returns the native memory address of the ArrayBuffer.</vk-property-description>

        <vk-syntax>
          <pre><code class="language-js">let byteLength = 8;
let buffer = new ArrayBuffer(byteLength);
let address = buffer.getAddress();</code></pre>
        </vk-syntax>

      </vk-property-entry>

      <!-- fromAddress -->
      <vk-property-entry>
        <vk-property-prototype>ArrayBuffer.<vk-prototype-name>fromAddress</vk-prototype-name></vk-property-prototype>
        <vk-property-type type="arraybuffer"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a></vk-property-type>
        <vk-property-description>Returns a new ArrayBuffer for the given memory address.</vk-property-description>

        <vk-syntax>
          <pre><code class="language-js">let byteLength = 8;
let dataPtr = { $: 0n };
vkMapMemory(device, memory, 0n, byteLength, 0, dataPtr);
let mappedBuffer = ArrayBuffer.fromAddress(dataPtr.$, byteLength);

// memcpy
let srcView = new Uint8Array(data); // data to copy over
let dstView = new Uint8Array(mappedBuffer); // copy destination
dstView.set(srcView, 0x0); // fast copy</code></pre>
        </vk-syntax>

      </vk-property-entry>

    </vk-properties>

  </vk-struct>

</vk-centered>

<script>
const IS_ROOT = false;
</script>

<script type="text/javascript" src="../../assets/js/prism.min.js"></script>
<script type="text/javascript" src="../../assets/js/index.js"></script>
